<?php

require(__DIR__ . '/../vendor/autoload.php');

function d(...$args){
    foreach ($args as $arg){
        var_dump($arg);
    }
    exit;
}

$tf = new \WebUtil\Matrix\Transform();

$data = <<<EOF
jack 男 21
tom 女 22
EOF;

$data2 = <<<EOF
1 a  www.baidu.com/a
2 b  www.qq.com/b
3 c  www.sin.com/c
EOF;

$data3 = <<<EOF
100
200
EOF;



//$userList = $tf->format($data , ['username','sex','age']);
//$rs = $tf->mix($userList , ['address' => 'xxx']);

$csv = \WebUtil\Matrix\CsvExport::instance([
    'username' => '用户名',
    'age' => '年龄',
    'sex' => '性别',
    'cid' => 'cid',
    'title' => 'title',
    'view' => '点击量'
],'1.csv');

//$csv->setTransform(function ($item){
//    return ["insert into user value({$item['username']})"];
//});


$r = $tf->process(
    new \WebUtil\Matrix\Layer\Str2ArrayLayer($data,['username','sex','age']),
    new \WebUtil\Matrix\Layer\Str2ArrayLayer($data2,['cid','title']),
    new \WebUtil\Matrix\Layer\Str2ArrayLayer($data3,['view']),
    new \WebUtil\Matrix\Layer\CrossSetLayer(),
    //$tf->first(),
    $csv
);
